package com.github.thinwonton.springboot.showcase.jta.mybatisplus.user.service;

import com.github.thinwonton.springboot.showcase.jta.mybatisplus.user.dao.UserDao;
import com.github.thinwonton.springboot.showcase.jta.mybatisplus.user.domain.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class UserService {

    @Autowired
    private UserDao userDao;

    @Transactional(rollbackFor = Exception.class)
    public void createUser(String name) {
        User user = new User();
        user.setName(name);
        userDao.insert(user);
    }
}
